﻿using LuShanTea.Admin.Web.App_Start;
using LuShanTea.DTO;
using LuShanTea.IService;
using LuShanTea.Web.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace LuShanTea.Admin.Web.Controllers
{
    public class CollectController : Controller
    {
        public ICollectService collectSer { get; set; }
        public IGoodService goodSer { get; set; }
        // GET: Collect
        [CheckPermission("Collect.List")]
        public ActionResult List(long userId = 1)
        {
            var model = collectSer.GetAll();
            return View(model);
        }
        // 添加商品收藏
        [HttpGet]
        [CheckPermission("Collect.Add")]
        public ActionResult AddNew()
        {
            return View();
        }
        // 软删除
        [CheckPermission("Collect.Delete")]
        public ActionResult Delete(long collectId)
        {
            collectSer.MakeDelete(collectId);
            return Json(new AjaxResult { Status = "ok" });
        }
        // 批量删除
        [CheckPermission("Collect.BatchDel")]
        public ActionResult BatchDel(long[] collectIds)
        {
            foreach (var collectId in collectIds)
            {
                collectSer.MakeDelete(collectId);
            }
            return Json(new AjaxResult { Status = "ok" });
        }
    }
}